#include "Includes.h"
#include "Xmon.h"
#include "EdoController/EdoControllerEditorWrapper.h"
#include "EdoController/EdoModulatorManager.h"

AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
    return new Xmon();
}

//==============================================================================
Xmon::Xmon() : editor(0)
{
	Log (T("Xmon::ctor"));

	EdoModulatorManager::getInstance();

	if (editor == 0)
	{
		editor = new XmonEditor (this);
	}
}

Xmon::~Xmon()
{
	Log (T("Xmon::dtor"));
	
	if (editor)
	{
		deleteAndZero (editor);
	}

	EdoModulatorManager::deleteInstance();
}

//==============================================================================
const String Xmon::getName() const
{
    return "Xmon";
}

int Xmon::getNumParameters()
{
    return 1;
}

float Xmon::getParameter (int index)
{
    return (0.0f);
}

void Xmon::setParameter (int index, float newValue)
{
    if (index == 0)
    {
    }
}

const String Xmon::getParameterName (int index)
{
    return String::empty;
}

const String Xmon::getParameterText (int index)
{
    return String::empty;
}

const String Xmon::getInputChannelName (const int channelIndex) const
{
    return String (channelIndex + 1);
}

const String Xmon::getOutputChannelName (const int channelIndex) const
{
    return String (channelIndex + 1);
}

bool Xmon::isInputChannelStereoPair (int index) const
{
    return false;
}

bool Xmon::isOutputChannelStereoPair (int index) const
{
    return false;
}

bool Xmon::acceptsMidi() const
{
    return true;
}

bool Xmon::producesMidi() const
{
    return true;
}

void Xmon::prepareToPlay (double sampleRate, int samplesPerBlock)
{
}

void Xmon::releaseResources()
{
}

void Xmon::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
	if (editor)
	{
		editor->processBlock (midiMessages);
	}
}

AudioProcessorEditor* Xmon::createEditor()
{
    return new EdoControllerEditorWrapper (this, editor);
}

//==============================================================================
void Xmon::getStateInformation (MemoryBlock& destData)
{
	Log (T("JunoController::getStateInformation"));
}

void Xmon::setStateInformation (const void* data, int sizeInBytes)
{
	Log (T("JunoController::getStateInformation"));
}
